package com.asnike.util{
	
	public class ASArray{
		
		static public function shuffle( $source:Array ):Array{
			var result:Array;
			
			result = $source.concat();
			result.sort( randomSort );
			
			return result;
		}
		static private function randomSort( $a:*, $b:* ):Number{
			if( Math.random() < 0.5 ){
				return -1;
			}else{
				return 1;
			} 
		}
		
		static public function hasItem( $item:*, $source:Array ):Boolean{
			if( $source.indexOf( $item ) > -1 ){
				return true;
			}
			return false;
		}
		
		static public function getItemIndex( $item:*, $source:Array ):int{
			return $source.indexOf( $item );
		}
		
		static public function addItem( $item:*, $source:Array ):void{
			$source[$source.length] = $item;
		}
		
		static public function addItemAt( $item:*, $index:int, $source:Array ):void{
			$source.splice( $source, 0, $item );
		}
	}
}